// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov  Date: 4/12/2007 09:13:09
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   I18n.java

package utility;

import java.util.*;

// Referenced classes of package de.escape.quincunx.i18n:
//            ResourceBundleCollection

public class I18n
{

    public static void addAppResourceBase(String base)
    {
        appResourceBases.addElement(base);
        resourceBundles.clear();
    }

    public static void setDefaultLocale(Locale l)
    {
        if(l == null)
            l = Locale.getDefault();
        defaultLocale = l;
    }

    private static final ResourceBundle getBundle(Locale l)
        throws MissingResourceException
    {
        if(l == null)
            l = defaultLocale;
        ResourceBundle res = (ResourceBundle)resourceBundles.get(l);
        if(res == null)
        {
            if(appResourceBases.size() == 0)
                throw new MissingResourceException("No application specific resource base defined", "<unknown>", "");
            ResourceBundleCollection collect = new ResourceBundleCollection();
            for(Enumeration e = appResourceBases.elements(); e.hasMoreElements(); collect.addResourceBundle(ResourceBundle.getBundle((String)e.nextElement(), l)));
            resourceBundles.put(l, collect);
            return collect;
        } else
        {
            return res;
        }
    }

    public static String getString(String tag)
        throws MissingResourceException
    {
        return getBundle(null).getString(tag);
    }

    public static String getString(String tag, Locale l)
        throws MissingResourceException
    {
        return getBundle(l).getString(tag);
    }

    public static String format(String tag, String args[], Locale l)
        throws MissingResourceException
    {
        return Utility.compileString(tag, args, getBundle(l));
    }

    public static String format(String tag, String arg, Locale l)
        throws MissingResourceException
    {
        return Utility.compileString(tag, new String[] {
            arg
        }, getBundle(l));
    }

    public static String format(String tag, String args[])
        throws MissingResourceException
    {
        return Utility.compileString(tag, args, getBundle(null));
    }

    public static String format(String tag, String arg)
        throws MissingResourceException
    {
        return Utility.compileString(tag, new String[] {
            arg
        }, getBundle(null));
    }

    public static Locale getDefaultLocale()
    {
        return defaultLocale;
    }

    public I18n()
    {
    }

    static boolean DEBUG;
    protected static Hashtable resourceBundles = new Hashtable(89);
    protected static Vector appResourceBases = new Vector(1);
    protected static Locale defaultLocale = Locale.getDefault();

    static 
    {
        addAppResourceBase("de.escape.quincunx.i18n.BasicResourceBundle");
    }
}